{
    "cells": [
        {
            "cell_type": "markdown",
            "id": "7fc13177-7d9d-4959-bbe9-fa26d60ea786",
            "metadata": {},
            "source": [
                "# Make Demo\n",
                "\n",
                "We show how GPT Index can fit with your Make.com workflow by sending the GPT Index response to a scenario webhook."
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "d2289d27",
            "metadata": {},
            "outputs": [],
            "source": [
                "import logging\n",
                "import sys\n",
                "\n",
                "logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
                "logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 2,
            "id": "f90c60a6-50b3-4b66-abf3-9723dac8a045",
            "metadata": {},
            "outputs": [],
            "source": [
                "from llama_index import GPTSimpleVectorIndex\n",
                "from llama_index.readers import MakeWrapper"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 5,
            "id": "dd8885c5-39e2-444b-9666-5032ab4cb50d",
            "metadata": {},
            "outputs": [],
            "source": [
                "# load index from disk\n",
                "index = GPTSimpleVectorIndex.load_from_disk('../vector_indices/index_simple.json')"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "id": "e5f7d888-01ed-40f7-9216-6c7340b229bf",
            "metadata": {},
            "outputs": [],
            "source": [
                "# set Logging to DEBUG for more detailed outputs\n",
                "# query index\n",
                "query_str = \"What did the author do growing up?\"\n",
                "response = index.query(query_str)"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 11,
            "id": "eaf06ad9-ba04-42fb-a7c8-daf7a5320b53",
            "metadata": {},
            "outputs": [],
            "source": [
                "# Send response to Make.com webhook\n",
                "wrapper = MakeWrapper()\n",
                "wrapper.pass_response_to_webhook(\n",
                "    \"<webhook_url>,\n",
                "    response,\n",
                "    query_str\n",
                ")"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3 (ipykernel)",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.11.1"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 5
}